package com.oj.friend.controller.user;

import com.oj.api.domain.vo.UserQuestionResultVO;
import com.oj.common.core.constants.Constants;
import com.oj.common.core.constants.JudgeConstants;
import com.oj.common.core.controller.BaseController;
import com.oj.common.core.domain.R;
import com.oj.friend.domain.question.dto.QuestionResultQueryDTO;
import com.oj.friend.domain.user.dto.UserSubmitDTO;
import com.oj.friend.service.IUserQuestionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author bin
 * @Date 2025/6/26
 */

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {

    @Resource
    private IUserQuestionService userQuestionService;

    @PostMapping("/submit")
    public R<UserQuestionResultVO> submit(@RequestBody UserSubmitDTO userSubmitDTO) {
        System.out.println(userSubmitDTO.getUserCode());
        R<UserQuestionResultVO> submit = userQuestionService.submit(userSubmitDTO);
        String exeMessage = submit.getData().getExeMessage();
        System.out.println(exeMessage);
        return submit;
    }

    @PostMapping("/rabbit/submit")
    public R<UserQuestionResultVO> rabbitSubmit(@RequestBody UserSubmitDTO userSubmitDTO) {
        R<UserQuestionResultVO> submit = userQuestionService.rabbitSubmit(userSubmitDTO);
        return submit;
    }

    @GetMapping("/exe/result")
    public R<UserQuestionResultVO> exeResult(Long examId, Long questionId, String currentTime) {
        return userQuestionService.exeResult(examId, questionId, currentTime);
    }
}
